package com.me.waterphase;

import java.util.ArrayList;
import java.util.Iterator;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.me.waterphase.listener.contact.EnergyContact;
import com.me.waterphase.utils.PhysicManager;

public class WaterEnergySource {

	private Body body;
	private float diffusedEnergy; //Per second.
	private ArrayList<Object> affectedObjects;
	
	public WaterEnergySource(float _x, float _y, float _width, float _height, float _diffusedEnergyPerSecond)
	{
		body = PhysicManager.createRectBody(BodyType.StaticBody, _x, _y, 0, 0, 0, _width, _height,false, false, false, false);
		diffusedEnergy = _diffusedEnergyPerSecond;
		affectedObjects = new ArrayList<Object>();
		
		Fixture fix = null;
		for(Iterator<Fixture> it = body.getFixtureList().iterator(); it.hasNext();)
		{
			fix = it.next();
			if(fix.getUserData() == null)
				fix.setUserData(new EnergyContact(this));
		}
	}
	
	//Getter.
	public EnergyContact getEnergyContact(){return (EnergyContact) body.getFixtureList().get(0).getUserData();}
	public Body getBody(){return body;}
	public float getDiffusedEnergyPerSecond() {return diffusedEnergy;}
	public ArrayList<Object> getAffectedObjects() {return affectedObjects;}
}
